/*     */ package com.newcrm.webapi.sub;
/*     */ 
/*     */ import com.newcrm.bean.User;
/*     */ import com.newcrm.db.UserManager;
/*     */ import com.newcrm.exception.DBException;
/*     */ import com.newcrm.exception.NotFoundException;
/*     */ import com.newcrm.util.Util;
/*     */ import com.newcrm.webapi.AbstractAction;
/*     */ import com.newcrm.webapi.AbstractHttpServlet;
/*     */ import java.io.IOException;
/*     */ import java.io.PrintWriter;
/*     */ import java.sql.SQLException;
/*     */ import java.util.HashMap;
/*     */ import java.util.Map;
/*     */ import javax.servlet.ServletException;
/*     */ import javax.servlet.http.HttpServletRequest;
/*     */ import javax.servlet.http.HttpServletResponse;
/*     */ import net.sf.json.JSONObject;
/*     */ import org.apache.log4j.Logger;
/*     */ 
/*     */ public class UpdateUserExtInfo extends AbstractAction
/*     */ {
/*  33 */   private static Logger logger = Logger.getLogger(UpdateUserExtInfo.class
/*  34 */     .getName());
/*     */ 
/*  36 */   private String id = null;
/*     */ 
/*     */   public UpdateUserExtInfo(AbstractHttpServlet servlet, String id) {
/*  39 */     super(servlet);
/*  40 */     this.id = id;
/*     */   }
/*     */ 
/*     */   public UpdateUserExtInfo(AbstractHttpServlet servlet) {
/*  44 */     super(servlet);
/*     */   }
/*     */ 
/*     */   public void parse(HttpServletRequest request, HttpServletResponse response)
/*     */     throws IOException, ServletException, NotFoundException
/*     */   {
/*  51 */     response.setContentType("text/html;charset=utf-8");
/*  52 */     PrintWriter out = response.getWriter();
/*  53 */     JSONObject jsonObject = new JSONObject();
/*     */ 
/*  55 */     User user = super.getLoginUser(request);
/*     */ 
/*  57 */     if ((!user.userId.equals(this.id)) && (!user.isAdmin)) {
/*  58 */       jsonObject.put("error", "1");
/*  59 */       out.println(jsonObject);
/*  60 */       out.flush();
/*  61 */       out.close();
/*  62 */       return;
/*     */     }
/*     */ 
/*  65 */     int pageNum = Util.getURLIntParameter(request.getParameter("pageNum"));
/*  66 */     if (pageNum <= 0) {
/*  67 */       pageNum = 10;
/*     */     }
/*  69 */     String customerFieldTypeIds = Util.getURLParameter(request
/*  70 */       .getParameter("customerFieldTypeIds"));
/*     */ 
/*  72 */     UserManager manager = new UserManager();
/*     */     try {
/*  74 */       manager.updateExtInfo(this.id, 1, 
/*  75 */         String.valueOf(pageNum));
/*     */ 
/*  77 */       manager.updateExtInfo(this.id, 4, 
/*  78 */         customerFieldTypeIds);
/*     */ 
/*  80 */       jsonObject.put("error", "0");
/*     */ 
/*  83 */       User updateUser = super.getUser(request, this.id);
/*     */ 
/*  86 */       if (updateUser.extInfo == null) {
/*  87 */         updateUser.extInfo = new HashMap();
/*     */       }
/*  89 */       updateUser.extInfo.put(Integer.valueOf(1), 
/*  90 */         String.valueOf(pageNum));
/*     */ 
/*  92 */       updateUser.extInfo.put(Integer.valueOf(4), 
/*  93 */         customerFieldTypeIds);
/*     */     }
/*     */     catch (DBException e) {
/*  96 */       jsonObject.put("error", "1");
/*  97 */       logger.warn("update user ext info failed", e);
/*     */     } catch (SQLException e) {
/*  99 */       jsonObject.put("error", "1");
/* 100 */       logger.warn("update user ext info failed", e);
/*     */     }
/* 102 */     out.println(jsonObject);
/* 103 */     out.flush();
/* 104 */     out.close();
/*     */   }
/*     */ }

/* Location:           C:\E\referenceProject\CRM参考\qikebao\WEB-INF\lib\qikebao.jar
 * Qualified Name:     com.newcrm.webapi.sub.UpdateUserExtInfo
 * JD-Core Version:    0.6.1
 */